//
//  shopCarHeaderView.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/6/13.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "shopCarHeaderView.h"

@implementation shopCarHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self shopCarView];
    }
    return self;
}

- (void)shopCarView
{

    //图
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    imageView.image = [UIImage imageNamed:@"gouwuche_3"];
    [self addSubview:imageView];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont systemFontOfSize:12];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"购物车空空如也 ~ ";
    titleLabel.textColor = [UIColor grayColor];
    [self addSubview:titleLabel];
    

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.layer.cornerRadius = 5;
    button.layer.masksToBounds = YES;
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [button setTitle:@"去逛逛" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button setBackgroundColor:DEFAULT_COLOR];
    [button addTarget:self action:@selector(shopCArBtnDidClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    
    //细线
    UIView *ThreadView = [[UIView alloc] init];
    ThreadView.backgroundColor = [UIColor blackColor];
    ThreadView.alpha = 0.1;
    [self addSubview:ThreadView];
    
    UILabel *likeLabel = [[UILabel alloc] init];
    likeLabel.font = [UIFont systemFontOfSize:12];
    likeLabel.textAlignment = NSTextAlignmentCenter;
    likeLabel.text = @"猜你喜欢";
//    likeLabel.textColor = [UIColor grayColor];
    likeLabel.backgroundColor = [UIColor whiteColor];
    [self addSubview:likeLabel];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(self.mas_top).with.offset(self.Height/10);
        make.height.mas_equalTo(self.Height/4);
        make.width.mas_equalTo(self.width/4);
    }];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(imageView.mas_bottom).with.offset(self.Height/8);
        make.height.mas_equalTo(15);
        make.width.mas_equalTo(100);
    }];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(titleLabel.mas_bottom).with.offset(15);
        make.height.mas_equalTo(self.Height/7);
        make.width.mas_equalTo(WIDTH/4);
    }];
    
    [ThreadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(button.mas_bottom).with.offset(self.Height/7);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(WIDTH-10);
    }];
    
    [likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(ThreadView.mas_centerY);
        make.width.mas_equalTo(WIDTH/4);
    }];
    
}

- (void)shopCArBtnDidClick:(UIButton *)button
{
    if ([self.delegate respondsToSelector:@selector(shopCarHeaderButtonDidClick:)]) {
        
        [self.delegate shopCarHeaderButtonDidClick:button];
    }
}

@end
